var prefix = jsctx + "/shopGoods";

var addShoping = (function () {
    function init() {
        setTimeout(function () {//防止先于-读取缓存执行
            // load();
        }, 10)
    };

    $('#exampleTable').on('load-success.bs.table', function (e, data) {
        if (data.total && !data.rows.length) {
            $('#exampleTable').bootstrapTable('selectPage').bootstrapTable('refresh');
        }
    });

    function reLoad() {
        $(".fixed-table-header-columns").css("display", "none");
        $(".fixed-table-body-columns").css("display", "none");
        $('#exampleTable').bootstrapTable('refresh');
    }

    function addMemberRefundApply() {
        location.href = prefix + "/addMemberRefundApply";
    }

    function getMemberRefundApplyDetail(refundApplyId) {
        location.href = prefix + "/getMemberRefundApplyDetail/" + refundApplyId;
    }

    var isajaxsendForPass = true;

    function updateStatusForPass(refundApplyId) {
        isajaxsendForPass = false;
        layer.confirm('确认处理此条申请？</br>(确认后请及时根据用户信息联系转账)', {
            btn: ['确定', '取消']
        }, function (index) {
            if (!isajaxsendForPass) {
                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: {
                        'refundApplyId': refundApplyId,
                        'status': '1'
                    },
                    beforeSend: function () {
                        isajaxsendForPass = true;
                    },
                    success: function (data) {
                        isajaxsendForPass = true;
                        layer.close(index);
                        if (data.status == 200) {
                            layer.msg("处理成功");
                            reLoad();
                        } else {
                            isajaxsendForPass = true;
                            layer.msg(data.message);
                            reLoad();
                        }
                    }
                });
            }
        })
    }

    function updateStatusForPassVerification(refundApplyId) {

        if ($('#isVerification').val() == '0') {
            $('#exampleModalVerification').modal('show')

            $("#submitVerificationForm").unbind("click").bind("click", function () {
                var formData = new FormData();
                formData.append("refundApplyId", refundApplyId);
                formData.append("status", "1");
                formData.append("authCode", $("#authCode").val());

                var isajaxVerification = true;

                if (isajaxVerification) {
                    $.ajax({
                        url: prefix + "/updateMemberRefundApplyStatus",
                        type: "post",
                        data: formData,
                        dataType: "json",
                        processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                        contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                        beforeSend: function () {
                            isajaxVerification = false;
                        },
                        success: function (data) {
                            if (data.status == 200) {
                                isajaxVerification = true;
                                parent.layer.msg("操作成功");
                                $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                    document.getElementById("contentFormVerification").reset();
                                })
                                $('#exampleModalVerification').modal('hide')
                                reLoad();
                            } else {
                                isajaxVerification = true;
                                parent.layer.alert(data.message);
                                $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                    document.getElementById("contentFormVerification").reset();
                                })
                                $('#exampleModalVerification').modal('hide')
                                reLoad();
                            }

                        }
                    })
                }

            })
        }
        if ($('#isVerification').val() == '1') {
            var formData = new FormData();
            formData.append("refundApplyId", refundApplyId);
            formData.append("status", "1");
            var isajaxVerification = true;
            if (isajaxVerification) {
                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: formData,
                    dataType: "json",
                    processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                    beforeSend: function () {
                        isajaxVerification = false;
                    },
                    success: function (data) {
                        if (data.status == 200) {
                            isajaxVerification = true;
                            parent.layer.msg("操作成功");
                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                document.getElementById("contentFormVerification").reset();
                            })
                            $('#exampleModalVerification').modal('hide')
                            reLoad();
                        } else {
                            isajaxVerification = true;
                            parent.layer.alert(data.message);
                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                document.getElementById("contentFormVerification").reset();
                            })
                            $('#exampleModalVerification').modal('hide')
                            reLoad();
                        }

                    }
                })
            }
        }
    }


    function updateStatusForOverrule(refundApplyId) {
        $('#exampleModal').modal('show')

        $("#submitForm").unbind("click").bind("click", function () {

            var formData = new FormData();
            formData.append("remark", $("#remark").val());
            formData.append("refundApplyId", refundApplyId);
            formData.append("status", "2");
            $.ajax({
                url: prefix + "/updateMemberRefundApplyStatus",
                type: "post",
                data: formData,
                dataType: "json",
                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data.status == 200) {
                        parent.layer.msg("操作成功");
                        $('#exampleModal').on('hidden.bs.modal', function () {
                            document.getElementById("contentForm").reset();
                        })
                        $('#exampleModal').modal('hide')
                        reLoad();
                    } else {
                        parent.layer.alert(data.message);
                        $('#exampleModal').on('hidden.bs.modal', function () {
                            document.getElementById("contentForm").reset();
                        })
                        $('#exampleModal').modal('hide')
                    }

                }
            })
        })
    }


    /*------  验证码  -----*/
    var num1 = 60;
    var ajaxReady = true;

    function getMemberRefundAuthCode() {
        if (ajaxReady) {
            $.ajax({
                url: prefix + "/getMemberRefundAuthCode",
                type: "POST",
                data: $('#authCode').val(),
                beforeSend: function () {
                    ajaxReady = false;
                },
                success: function (data) {
                    if (data.status == 200) {
                        time();

                        function time() {
                            if (num1 == 0) {
                                // $('#authCode').attr("disabled", "disabled")
                                $('#getMemberRefundAuthCode').text("获取验证码");
                                $('#getMemberRefundAuthCode').attr("onclick", 'memberRefundApply.getMemberRefundAuthCode()');
                                ajaxReady = true;
                                num1 = 60;
                            } else {
                                // $('#authCode').removeAttr('disabled')
                                $('#getMemberRefundAuthCode').html(num1 + "秒后重试");
                                $('#getMemberRefundAuthCode').removeAttr('onclick');
                                num1--;
                                setTimeout(function () {
                                    time()
                                }, 1000)
                            }
                        }
                    } else {
                        parent.layer.alert(data.message);
                        $('#authCode').removeAttr('disabled')
                        $('#getMemberRefundAuthCode').text("获取验证码");
                        $('#getMemberRefundAuthCode').attr("onclick", 'memberRefundApply.getMemberRefundAuthCode()');
                        ajaxReady = true;
                        num1 = 60;
                    }

                }
            })


        }
    };

    var isajaxsendForArrive = true;

    function updateStatusForArrive(refundApplyId) {
        if (isajaxsendForArrive) {
            layer.confirm('确认已到账？</br>(确认后将扣除用户余额中对应的提现金额，请确保用户余额充足且用户已收到您的退款)', {
                btn: ['确定', '取消']
            }, function (index) {

                $.ajax({
                    url: prefix + "/updateMemberRefundApplyStatus",
                    type: "post",
                    data: {
                        'refundApplyId': refundApplyId,
                        'status': '3'
                    },
                    beforeSend: function () {
                        isajaxsendForArrive = false;
                    },
                    success: function (data) {
                        isajaxsendForArrive = false;
                        setTimeout(function () {
                            isajaxsendForArrive = true;
                        }, 1500)
                        layer.close(index);
                        if (data.status == 200) {
                            layer.msg("操作成功");
                            reLoad();
                        } else {
                            layer.msg(data.message);
                        }
                    }
                });

            })
        }
    }

    function goBack() {
        window.history.back();
    }

    function exportMemberRefundApply() {
        $.fileDownload(prefix + "/exportMemberRefundApply", { // 后台请求链接
            httpMethod: "get",　　　　　　　　// 请求方式
            contentType: 'application/json',　 // 请求头
            data: {　　　　　　　　　　　　　　　// 参数，左边为后台接收的参数名，右边为前端获取的值，
                nickname: $("#nickname").val().trim(),
                mobile: $("#mobile").val().trim(),
                refundSource: $("#refundSource").val().trim(),
                outTradeNo: $("#outTradeNo").val().trim(),
                refundBy: $("#refundBy").val().trim(),
                memberMobile: $("#memberMobile").val().trim(),
                memberRealName: $("#memberRealName").val().trim(),
                status: $("#status").val().trim(),
                startTime: $("#startTime").val().trim(),
                endTime: $("#endTime").val().trim(),
                count: $("#count").val().trim() == '' ? 0 : $("#count").val().trim(),
                offset: $('.active .page-link').text(),
                limit: $(".page-size").text()
            },
            prepareCallback: function (url) {
                layer.msg("文件下载中...", {time: -1})
            },
            abortCallback: function (url) {
                // 异常终止
                layer.msg("文件下载异常！！");
            },
            successCallback: function (url) {
                layer.msg("文件下载成功！！", {time: 1500});
            },
            failCallback: function (data) {
                var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                layer.msg(JSON.parse(str).message);
            }
        })
    }

    function pdselect() {
        var rows = $("#exampleTable").bootstrapTable('getSelections');// 获得要删除的数据
        if (rows.length == 0) {// rows 主要是为了判断是否选中，下面的else内容才是主要
            alert("请先选择要处理的订单!");
            return;
        } else {
            var memberIds = new Array();// 声明一个数组
            var refundAmounts = new Array();
            var refundApplyIds = new Array();
            $(rows).each(function () {// 通过获得别选中的来进行遍历
                memberIds.push(this.memberId); // cid为获得到的整条数据中的一列
                refundAmounts.push(this.refundAmount);
                refundApplyIds.push(this.refundApplyId);
            });
            let sum = 0;
            for (let i = 0; i < refundAmounts.length; i++) {
                sum = sum + refundAmounts[i];
            }
            memberIdList = JSON.stringify(memberIds);
            refundApplyIdList = JSON.stringify(refundApplyIds);
            memberAdd(memberIdList, memberIds, sum, refundApplyIdList)
        }
    }

    function memberAdd(a, b, c, d) {
        isajaxsendForPass = false;
        var number = b.length;
        // var money = c;
        // var money = Math.round(Math.round((c*100)/100));
        var money = Math.floor(c * 100) / 100;
        layer.open({
                title: '批量处理',
                area: ['300px', '200px'],
                content: '勾选数量:' + number + '</br>' + '需退款金额:' + money,
                // + '</br>' + '备注:' + '</br>' + '<textarea id="sefix" rows="4" cols="33"></textarea>'
                btn: ['取消', '批量处理', '批量驳回',],
                yes: function (index, layero) {
                    layer.close(index);
                },

                btn2: function (index, layero) {
                    // console.log($('#isVerification').val());
                    if ($('#isVerification').val() == '0') {
                        $('#exampleModalVerification').modal('show');
                        // console.log($("#sefix").val());
                        // var text = $("#sefix").val();
                        $("#submitVerificationForm").unbind("click").bind("click", function () {
                            var formData = new FormData();
                            formData.append("refundApplyIdsJson", d);
                            formData.append("status", "1");
                            formData.append("authCode", $("#authCode").val());
                            // formData.append("remark", text);
                            var isajaxVerification = true;

                            if (isajaxVerification) {
                                $.ajax({
                                    url: prefix + "/batchUpdateMemberRefundApplyStuts",
                                    type: "post",
                                    data: formData,
                                    dataType: "json",
                                    processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                                    beforeSend: function () {
                                        isajaxVerification = false;
                                    },
                                    success: function (data) {
                                        // if (data.status == 200 && data.message == null) {
                                        //     isajaxVerification = true;
                                        //     parent.layer.msg("操作成功");
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     reLoad();
                                        //
                                        // }else if (data.status == 200 && data.message != null){
                                        //     // parent.layer.msg("data");
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     layer.open({
                                        //         title:'信息提示',
                                        //         area:['300px','300px'],
                                        //         content:data.message,
                                        //         btn: ['确定'],
                                        //         success:function () {
                                        //              reLoad();
                                        //         }
                                        //
                                        // })}
                                        // else {
                                        //     isajaxVerification = true;
                                        //     parent.layer.alert(data.message);
                                        //     $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                        //         document.getElementById("contentFormVerification").reset();
                                        //     })
                                        //     $('#exampleModalVerification').modal('hide')
                                        //     reLoad();
                                        // }
                                        if (data.status == 200 && data.message == "") {
                                            isajaxVerification = true;
                                            parent.layer.msg("操作成功");
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            })
                                            $('#exampleModalVerification').modal('hide');
                                            reLoad();
                                        } else if (data.status == 200 && data.message != "") {
                                            isajaxVerification = true;
                                            // parent.layer.msg("操作成功");
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            });
                                            $('#exampleModalVerification').modal('hide');
                                            layer.open({
                                                title: '信息提示',
                                                area: ['300px', '200px'],
                                                content: data.message,
                                                btn: ['确定']

                                            });
                                            reLoad();
                                        } else {
                                            isajaxVerification = true;
                                            parent.layer.alert(data.message);
                                            $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                                document.getElementById("contentFormVerification").reset();
                                            });
                                            $('#exampleModalVerification').modal('hide');
                                            reLoad();
                                        }

                                    }
                                })
                            }

                        })
                    }
                    if ($('#isVerification').val() == '1') {
                        var formData = new FormData();
                        formData.append("refundApplyIdsJson", d);
                        formData.append("status", "1");
                        var isajaxVerification = true;
                        if (isajaxVerification) {
                            $.ajax({
                                url: prefix + "/batchUpdateMemberRefundApplyStuts",
                                type: "post",
                                data: formData,
                                dataType: "json",
                                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                                beforeSend: function () {
                                    isajaxVerification = false;
                                },
                                success: function (data) {
                                    if (data.status == 200 && data.message == "") {
                                        isajaxVerification = true;
                                        parent.layer.msg("操作成功");
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide');
                                        reLoad();
                                    } else if (data.status == 200 && data.message != "") {
                                        isajaxVerification = true;
                                        // parent.layer.msg("操作成功");
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide');
                                        layer.open({
                                            title: '信息提示',
                                            area: ['300px', '200px'],
                                            content: data.message,
                                            btn: ['确定']

                                        });
                                        reLoad();
                                    } else {
                                        isajaxVerification = true;
                                        parent.layer.alert(data.message);
                                        $('#exampleModalVerification').on('hidden.bs.modal', function () {
                                            document.getElementById("contentFormVerification").reset();
                                        })
                                        $('#exampleModalVerification').modal('hide')
                                        reLoad();
                                    }
                                }
                            })
                        }
                    }

                },
                btn3: function (index, layero) {

                    $('#exampleModal').modal('show')

                    $("#submitForm").unbind("click").bind("click", function () {

                        var formData = new FormData();
                        formData.append("remark", $("#remark").val());
                        formData.append("refundApplyIdsJson", d);
                        formData.append("status", "2");
                        $.ajax({
                            url: prefix + "/batchUpdateMemberRefundApplyStuts",
                            type: "post",
                            data: formData,
                            dataType: "json",
                            processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                            contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                            success: function (data) {
                                if (data.status == 200 && data.message == "") {
                                    // layer.msg("操作成功");
                                    parent.layer.msg("操作成功");
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    reLoad();
                                } else if (data.status == 200 && data.message != "") {
                                    // layer.msg("请填写备注");
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    layer.open({
                                        title: '信息提示',
                                        area: ['300px', '200px'],
                                        content: data.message,
                                        btn: ['确定']

                                    })
                                    reLoad();

                                } else {
                                    // layer.msg('操作失败');
                                    parent.layer.alert(data.message);
                                    $('#exampleModal').on('hidden.bs.modal', function () {
                                        document.getElementById("contentForm").reset();
                                    })
                                    $('#exampleModal').modal('hide')
                                    reLoad();
                                }

                            }
                        })
                    })


                }
            }
        )
    }

    return {
        init: init,
        goBack: goBack,
        reLoad: reLoad,
        updateStatusForPass: updateStatusForPass,
        updateStatusForOverrule: updateStatusForOverrule,
        addMemberRefundApply: addMemberRefundApply,
        getMemberRefundApplyDetail: getMemberRefundApplyDetail,
        updateStatusForArrive: updateStatusForArrive,
        exportMemberRefundApply: exportMemberRefundApply,
        updateStatusForPassVerification: updateStatusForPassVerification,
        getMemberRefundAuthCode: getMemberRefundAuthCode,
        memberAdd: memberAdd,
        pdselect: pdselect
    };
})();

var addShoping = (function () {
    function init() {

        // beforeValidate();
        validateRule();
    };

    function beforeValidate() {
        // alert(1)
        if ($('#imageBroadcast1_file').val() == '' && $('#imageBroadcast2_file').val() == '' && $('#imageBroadcast3_file').val() == '' && $('#imageBroadcast4_file').val() == '' && $('#imageBroadcast5_file').val() == '') {

            // layer.alert('至少添加一张商品banner图')
            $('#coman5').append("<i class='fa fa-times-circle'></i> " + '至少上传一张商品banner图');
            return false;
        }
    }

    function getCheckedRoles() {
        var adIds = "";
        $("input:checkbox[name=role]:checked").each(function (i) {
            if (0 == i) {
                adIds = $(this).val();
            } else {
                adIds += ("," + $(this).val());
            }
        });
        return adIds;
    }

    var isajaxsend = true;

    function save() {

        if (isajaxsend) {
            var formData = new FormData($("#addshoppic")[0]);
            for (var [a, b] of formData.entries()) {
                console.log(a, b);
            }
            if ($('#one_box').prop("checked") && $('#two_box').prop("checked")) {
                formData.delete("saleType")
                formData.append("saleType", "2")
            }
            // $("#roleIds").val(getCheckedRoles());
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + "/saveOrUpdateShopOrder",
                data: formData,
                processData: false,
                contentType: false,
                async: false,

                beforeSend: function () {
                    isajaxsend = false
                },
                error: function (request) {
                    isajaxsend = true
                    parent.layer.alert("Connection error");
                },
                success: function (data) {
                    if (data.status == 200) {
                        isajaxsend = false
                        parent.layer.msg("操作成功");
                        window.history.back();
                    } else {
                        isajaxsend = true
                        parent.layer.alert(data.message)
                    }

                }
            });
        }
    }

    var icon = "<i class='fa fa-times-circle'></i> ";
    // var gcon = "<i class='fa fa-times-circle' style=''></i> ";
    // var icon2 = "<i class='fa fa-times-circle'></i> ";
    // jQuery.validator.addMethod("pic", function(value,element) {
    //     // alert(1)
    //     if( $('#imageBroadcast1_file').val() == ''&&$('#imageBroadcast2_file').val() == ''&&$('#imageBroadcast3_file').val() == ''&&$('#imageBroadcast4_file').val() == ''&&$('#imageBroadcast5_file').val() == ''){
    //
    //         layer.alert('至少添加一张商品banner图')
    //         return true;
    //     }},'156');

    function validateRule() {
        $("#addshoppic").validate({
            rules: {
                goodsName: {
                    required: true,
                    maxlength: 10
                },
                goodsPrice: {
                    required:true,
                    number:true,
                    min:0.01
                },

                docfile: {
                    required: true
                },
                goodsPoint: {
                    required: true,
                    digits: true
                },
                saleType: {
                    required: true
                },
                goodsContext: {
                    required: true,
                    maxlength: 200
                },
                // goodsImage_file:{
                //     required:true
                // }
                // imageBroadcast5_file:{
                //     pic:true
                // },
                // memberMobile: {
                //     required: true
                // },
                // memberRealName: {
                //     required: true
                // },
                // refundAmount: {
                //     required: true,
                //     min: 1
                // },
                // refundSource: {
                //     required: true,
                // },

            },
            messages: {
                goodsName: {
                    required: icon + "请输入商品名称",
                    maxlength: icon + "最多输入10个汉字"
                },
                docfile: {
                    required: icon + "此图必选"
                },
                goodsPoint: {
                    required: icon + "请输入积分单价",
                    digits: icon + "请输入整数"
                },
                goodsPrice: {
                    required: icon + "请输入实际单价"
                },
                saleType: {
                    required: function () {
                        $('#reface').append("<label id=\"saleType-error\" class=\"error\" for=\"saleType\"><i class=\"fa fa-times-circle\"></i> 此选项必填</label>");
                    }
                },
                goodsContext: {
                    required: icon + "请输入商品介绍",
                    maxlength: icon + "最多输入两百字"
                }
                // goodsImage_file:{
                //     required:function () {
                //  $('#coman').after("<label id=\"goodsImage_file-error\" class=\"error\" for=\"goodsImage_file\"><i class=\"fa fa-times-circle\"></i> 此图必选</label>")
                //     }
                // }

                // memberMobile: {
                //     required: icon + "请输入提现账户号码"
                // },
                // memberRealName: {
                //     required: icon + "请输入真实姓名"
                // },
                // refundAmount: {
                //     required: icon + "请输入退款金额",
                //     min: icon + "请输入大于1的金额",
                // },
                // refundSource: {
                //     required: icon + "请选择用户充电端",
                // },
            },


            submitHandler: function (form) {
                // alert(getObjectURL($('#imageBroadcast1_file').files[0]));
                var formed = new FormData($("#addshoppic")[0]);
                for (var [a, b] of formed.entries()) {
                    console.log(a, b);
                }

                if (formed.get('imageBroadcast1_file').name == '' && formed.get('imageBroadcast2_file').name == '' && formed.get('imageBroadcast3_file').name == '' && formed.get('imageBroadcast4_file').name == '' && formed.get('imageBroadcast5_file').name == '') {

                    layer.alert('至少添加一张商品banner图')
                    return false;
                }
                if (formed.get('goodsImage_file').name == '') {

                    layer.alert('请添加商品缩略图')
                    return false;
                }
                if (formed.get('imageDetail1_file').name == '') {

                    layer.alert('请添加商品详情图')
                    return false;
                }

                save();
            }
        })
    }

    // function getObjectURL(file) {
    //     var url = null;
    //     if (window.createObjectURL != undefined) {
    //         url = window.createObjectURL(file);
    //     } else if (window.URL != undefined) { // mozilla(firefox)
    //         url = window.URL.createObjectURL(file);
    //         // window.url.srcObject = file;
    //     } else if (window.webkitURL != undefined) { // webkit or chrome
    //         url = window.webkitURL.createObjectURL(file);
    //     }
    //     return url;
    // }

    return {
        init: init
    };
})();
